<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<base th:href="@{/}" />
<title>Insert title here</title>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/Managerstyle.css" />
<style>
span{
	font-size: 19px;
}
/* table{table-layout:fixed;word-break:break-all;} */
</style>
</head>
<body>
	<div class="contain">
		<h3>个人课程安排及成绩管理</h3>
		<input type="hidden" th:value="${session.loginTeacher.tid}" id="tid"  />
		教师名称：
		<span th:text="${session.loginTeacher.tname}"></span>
		<br>
		请选择学期：
		<select id="selectTyear" style="width: 150px">
			<option value="">请选择年份</option>
			<option th:each="year:${yearList}" th:value="${year}" th:text="${year}"></option>
		</select>
		<select id="selectTid" style="width: 150px">
			<option value="">请选择学期</option>
		</select>
		
		<button type="button" id="selectTerm">查询</button>
		<table class="table">
			<tr>
				<td width="190">开课计划号</td>
				<td width="190">课程名称</td>
				<td width="380">专业所属学院</td>
				<td width="230">专业</td>
				<td width="110">班级</td>
				<td width="110">操作</td>
			</tr>
			<tbody id="displayTable">
				
			</tbody>
		</table>
	</div>
	<script>
		$(document).ready(function(){
			
			$("#selectTerm").click(function(){
				$.ajax({
					url: "teach/selectCoursePlanByTermId",
					type: "GET",
					data: {termId: $("#selectTid").val(), tid: $("#tid").val()},
					success: function(data){
						$("#displayTable").empty();
						$.each(data,function(index,value){
							var str1 = "<tr>" + "<td>" + value.lessionPlan.term.termId + "</td>" + 
							"<td>" + value.lessionPlan.course.cname + "</td>" + 
							"<td>" + value.lessionPlan.major.acadamy.acdmname + "</td>" +
							"<td>" + value.lessionPlan.major.mjname + value.lessionPlan.term.tyear + "</td>" +
							"<td>" + value.batch.bname + "</td>" + 
							"<td><a href='teach/giveGrade?cpid=" + value.cpid + "&bid=" + value.batch.bid + "'>" + "评分</a></td>" +
							"</tr>";
							$("#displayTable").append(str1);
						});
					},
					error: function(req, status, error){
						
					}
				});
			});
			
			$("#selectTyear").change(function(){
				var str = "<option value=''>请选择年份</option>";
				$.ajax({
					url: "teach/selectTermByTyear",
					type: "GET",
					data: {tyear: $("#selectTyear").val()},
					success: function(data){
						$("#selectTid").empty();
						$.each(data, function(index,value){
							var str1 = "<option value='" + value.termId + "'>" + value.termName + "</option>";
							$("#selectTid").append(str1);
						});
					},
					error: function(req, status, error)	{
						$("#selectTid").empty();
						$("#selectTid").append(str);
					}
				});
			});
			
		});
	</script>

</body>
</html>